#include <bits/stdc++.h>
using namespace std;
int T,n,a[114514],b[20],ans;
void dfs(int step){
    if(step == n){
        int res = 0;
        for(int i=0;i<n;i++){
            for(int j=i-1;j>=0;j--){
                if(b[i] == b[j]){
                    if(a[i] == a[j] ) res += a[i];
                }
            }
        }
        ans = max(ans,res);
        return ;
    }
    b[step] = 0;
    dfs(step + 1);
    b[step] = 1;
    dfs(step + 1);
}
void solve(){
    ans = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    dfs(0);
    cout<<ans<<endl;
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--) solve();
}
